package com.lazy.dbdemo;


import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lazy.dbdemo.bean.HostCurstatus;
import com.lazy.dbdemo.service.JdbcServiceImpl;
import com.lazy.lib.db.JDBCConfig;
import com.lazy.lib.db.bonecp.DBConnPools;

/**
 * 启动数据库demo的入口 
 */
public class DbMain {
    private final static Logger logger = LoggerFactory.getLogger(DbMain.class);
    
    private JdbcServiceImpl serviceImpl;
    
    public DbMain(){
        JDBCConfig conf = getConfig();
        serviceImpl = JdbcServiceImpl.getService(conf);
        someOper();
        
        DBConnPools.releasePools();
    }

    public JDBCConfig getConfig() {
        JDBCConfig conf = new JDBCConfig("gpstest2", "oracle.jdbc.OracleDriver", "jdbc:oracle:thin:@192.168.1.252:1521:gpstest2",
                "gpstest", "gpstest");
        return conf;
    }
    
    public void someOper() {
        logger.info("date={}", serviceImpl.getDBsysTime());
        
        List<HostCurstatus> list = serviceImpl.queryHostCurstatus();
        for (HostCurstatus pos:list) {
            logger.info("pos={}", pos);
        }
    }
    
    
    public static void main(String[] args){
        new DbMain();
    }
}
